# Contributor: Chloe Kudryavtsev <code@toast.bunkerlabs.net>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=watchexec
pkgver=1.23.0
pkgrel=1
pkgdesc="Executes commands in response to file modifications"
url="https://github.com/watchexec/watchexec"
# riscv64: scopes test in ignore/tests/filtering.rs fails
# s390x: nix/libc crate
arch="all !riscv64 !s390x"
license="Apache-2.0"
makedepends="cargo cargo-auditable dbus-dev"
checkdepends="bash"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/watchexec/watchexec/archive/refs/tags/v$pkgver.tar.gz
	system-dbus.patch
	"
options="net"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --all --frozen
}

package() {
	install -Dm755 target/release/watchexec -t "$pkgdir"/usr/bin/
	install -Dm644 doc/watchexec.1 -t "$pkgdir"/usr/share/man/man1/

	install -Dm644 completions/bash \
		"$pkgdir"/usr/share/bash-completion/completions/watchexec
	install -Dm644 completions/fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/watchexec.fish
	install -Dm644 completions/zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_watchexec
}

sha512sums="
5eec64567a73fc3e124d7c29979f35fe5cac68ec7119303bb50c831eb00c248db0b12fe36eef45f9d6455e5793d1485b9641d7f719df3e11ec84d017c9d305c0  watchexec-1.23.0.tar.gz
2f2a4bc57ba0c9e887482d0aebf8f6eeb9ff98bbc7dca6a47facb09a39d2cee927e5cff2acdac6eef3de87b382143d748a732f6f9d759fbbdba52c2b751fed7a  system-dbus.patch
"
